﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace tp1
{
    public partial class FMain : Form
    {
        Labyrinthe lastLabyrinthe;

        public FMain()
        {
            InitializeComponent();
        }

        private void btnGenerer_Click(object sender, EventArgs e)
        {
            Console.WriteLine("Début de la génération");
            int m = (int)nudM.Value;
            int n = (int)nudN.Value;
            lastLabyrinthe = Labyrinthe.Create(n, m);
            pbLabyrinthe.Image = lastLabyrinthe.GetBitmap();
            Console.WriteLine("Labyrinthe dessiné: " + lastLabyrinthe.OpAffichage + " op.");
        }
        

        private void btnAffichage_Click(object sender, EventArgs e)
        {
            Console.WriteLine(lastLabyrinthe.ToString());
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.Filter = "Image JPEG | *.jpg";
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    lastLabyrinthe.GetBitmap().Save(sfd.FileName);
            }
        }
    }
}
